/*
 *  Plot Area Widget (where the data is plotted
 */ 

#ifndef PLOTAREA_H
#define PLOTAREA_H

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#include <QtGui/QBrush>
#include <QtGui/QPen>
#include <QtGui/QPixmap>
#include <QtGui/QWidget>
#include <QtGui/QFrame>
#include <QtGui/QRubberBand>
#include <QtGui/QPixmap>

#include <QDebug>

#include "mapgrab.h"


class PlotArea : public QFrame {

    Q_OBJECT

    int numXTick;
    int numYTick;

    bool storePosition;
    int  storeXPosition;
    int  storeYPosition;

    vector<float> plotData;

public:
    PlotArea( vector<float> &fData, QWidget *parent = 0 );

public slots:
	void placeHolder();

private slots:
    void updateMap(const QRect &r);

signals:
    void mousePosition( int x, int y, int dx, int dy);
    void updateLabel( int numXTicks, int numYTicks, float *xLocs, float *yLocs, float *xVals, float *yVals);

protected:
    void paintEvent( QPaintEvent *pev);
    bool eventFilter( QObject *, QEvent *ev);
    //void resizeEvent( QResizeEvent *rev);

private:
    void drawGrid();
    void findMaxMin(float *max, float *min);
	void plotPoints();
    void readData( vector<int> &data, vector<float> &plotData);
    void readData( vector<float> &data, vector<float> &plotData);
    void grabMap();

    QRubberBand *zoomBox;
    QPoint       mStart;
    QPixmap     *bgImage;
    MapGrab     *bgMap;
    bool resizeFlag;
    bool firstTime;

};

#endif
